start_hour = int(input())
start_minute = int(input())
duration = int(input())

total_minutes = start_minute + duration
end_hour = start_hour + total_minutes // 60
end_minute = total_minutes % 60

print(end_hour)
print(end_minute)